<template>
  <h1>猜数字练习</h1>
  <input type="text" v-model="a">
  <button @click="f">猜一猜</button>
  <h4>小提示：{{result}}</h4>
  {{num}}
</template>
<script setup>
import {ref} from "vue";
const num=parseInt(Math.random()*100)+1;
const index=ref('0')
const a=ref('');
const result=ref('');
const f=()=>{
  index.value++;
  if (a.value>num){
    result.value="猜大了";

  }else if(a.value<num){
    result.value="猜小了";

  }else{
    result.value="猜对了"+index.value;
  }
}


</script>


<style scoped>

</style>